#include <iostream>
using namespace std;
using LL = long long;
const int N = 2e5 + 7;
int a[N], c[N];
bool flag[N]; //0blue 1red
int main() {
	freopen("color.in", "r", stdin);
	freopen("color.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int T;
	cin >> T;
	while (T--) {
		int n, cnt = 0;
		cin >> n;
		for (int i = 1; i <= n; ++i)
			cin >> a[i];
		for (int i = 1; i <= n; ++i) {
			if (a[i] != a[i+1])
				++cnt;
		}
		if (cnt == n) { cout << 0 << '\n'; continue; }
		cout << "1";		
	}
}
